<!-- 轮播图、banner、焦点图 -->
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            *{
                margin: 0px;
                padding: 0px;
                list-style:none;
            }
            body{ 
             background-image:url(images/pic.q1.jpg);
             background-repeat: no-repeat;
             background-size:100% auto;   
              } 
            div{
                width: 590px;
                height: 470px;
                margin:100px auto;
                position: relative;
                overflow: hidden;
            }
            ul{
                width: 8888px;
            }
            ul li{
                float: left;
            }
            ol{
                position: absolute;
                bottom:20px;
                left: 50%;
                transform: translateX(-50%)
            }
            ol li{
                width: 10px;
                height: 10px;
                background:wheat;
                border-radius: 50%;
                margin:0px 4px;
                float: left;
                cursor: pointer;
            }
            span{
                position: absolute;
                background:#f60;
                border-radius: 10px;
                top:50%;
                transform: translateY(-50%);
                cursor: pointer;
            }
            span:nth-of-type(1){
                left: 10px;
            }
            span:nth-of-type(2){
                right: 10px;
            }
            .current{
                background:#f60;

            }
        </style>
    </head>
    <body>
        <div id="one">
            <ul id="two">
                <li>
                    <img src="images/pic.0001.jpg" alt="">
                </li>
                <li>
                    <img src="images/pic.0002.jpg" alt="">
                </li>
                <li>
                    <img src="images/pic.0003.jpg" alt="">
                </li>
                <li>
                    <img src="images/pic.0007.jpg" alt="">
                </li>
            </ul>

            <ol id="list">
                <li class="current"></li>
                <li></li>
                <li></li>
                <li></li>
            </ol>
            <span id="left">左</span>
            <span id="right">右</span>
        </div>
        <script>
            var two=document.getElementById('two');

            var one=document.getElementById('one');

            var right=document.getElementById('right');

            var left=document.getElementById('left');

            var list=document.getElementById('list').children

            var num=0;
            
            var timer;

            function fn(){

                timer=setInterval(function(){

                num++;

                if(num>3){

                    num=0;

                }

                var t=-num*590;
                 

                    two.style.transform='translateX('+t+'px)';
                    
                    for(var j=0;j<list.length;j++){

                        list[j].className='';

                    }
                   
                    list[num].className='current'

                },1000)

            }

            fn()
           
            one.onmouseenter=function(){

                clearInterval(timer)

            }

            
            one.onmouseleave=function(){

               fn()

            }

           
            for(var i=0;i<list.length;i++){
               
                list[i].index=i;

                list[i].onclick=function(){
                  
                    for(var j=0;j<list.length;j++){

                        list[j].className='';

                    }

                    this.className='current';
                    
                    num=this.index;

                    var t=-num*590;

                    
                    two.style.transform='translateX('+t+'px)';

                }
            }

            
            right.onclick=function(){

                num++;

                if(num>3){

                    num=0;

                }

                var t=-num*590;

                   
                    two.style.transform='translateX('+t+'px)';
                    
                    for(var j=0;j<list.length;j++){

                        list[j].className='';
                    }
                  
                    list[num].className='current'
            }
            left.onclick=function(){

                num--;

                if(num<0){

                    num=3;
                    
                }

                var t=-num*590;

                    
                    two.style.transform='translateX('+t+'px)';
                   
                    for(var j=0;j<list.length;j++){

                        list[j].className='';

                    }
                   
                    list[num].className='current'
            }

        </script>
    </body>
</html>